package com.niguang.work.api.controller;


import com.baomidou.mybatisplus.plugins.Page;
import com.niguang.common.pojo.Result;
import com.niguang.work.api.entity.ReformApply;
import com.niguang.work.api.entity.ReformContent;
import com.niguang.work.api.service.ReformContentService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;

/**
 * <p>
 * 'work.v_personSite' is not BASE TABLE 前端控制器
 * </p>
 *
 * @author 12380
 * @since 2018-09-06
 */
@RestController
@RequestMapping("/api/reformContent/")
public class ReformContentController {

    @Resource
    private ReformContentService reformContentService;


    /**
     * 增加--上报安全隐患或质量隐患
     *
     * @param reformContent
     * @return
     */
    @PostMapping("addReformContent")
    public Result addReformContent(@Valid ReformContent reformContent) {
        return reformContentService.addReformContent(reformContent);
    }

    /**
     * 我提交的隐患工单列表
     *
     * @param siteId   工地ID
     * @param formFlag 上报类型 1--安全隐患 2--质量隐患
     * @return
     */
    @GetMapping("getReformContent")
    public Result getReformContent(@NotNull Long siteId, @NotNull Integer formFlag, Page<ReformContent> page) {
        return reformContentService.getMyReformContent(siteId, formFlag, page);
    }

    /**
     * 获取首页列表标题
     *
     * @param siteId
     * @return
     */
    @GetMapping("getTitle")
    public Result getTitle(Long siteId, @NotNull @RequestParam Integer formFlag ){
        return reformContentService.getTitle(siteId,formFlag);
    }


    /**
     * 审核人查询列表
     *
     * @param siteId    工地ID
     * @param applyFlag 查询类型  1-待审核 2-无需整改 3-待整改
     * @param key       搜索关键字
     * @return
     */
    @GetMapping("getApplyList")
    public Result getApplyList(@NotNull Long siteId, @NotNull Integer menuType, @NotNull Integer formFlag,
                               @NotNull Integer applyFlag, String key, Page<ReformContent> page) {
        return reformContentService.getApplyList(siteId, menuType, formFlag, applyFlag, key, page);
    }

    /**
     * 审核人操作：生成整改单、无需整改；整改人操作：整改、驳回、转发；复查人操作：提交
     *
     * @param reformApply
     * @return
     */
    @PostMapping("addReformApply")
    public Result addReformApply(@Valid ReformApply reformApply) {
        return reformContentService.addReformApply(reformApply);
    }


}

